package com.cxhc.app.api;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.cxhc.app.api.mapper.RpConAdjustMapStructMapper;
import com.cxhc.app.api.mapper.RpSecInvestigationMapStructMapper;
import com.cxhc.app.api.vo.RpSecInvestigationVo;
import com.cxhc.system.domain.app.RpConAdjust;
import com.cxhc.system.domain.app.RpSecInvestigation;
import com.cxhc.system.service.app.IRpSecInvestigationService;
import com.github.pagehelper.PageHelper;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cxhc.common.annotation.Log;
import com.cxhc.common.core.controller.BaseController;
import com.cxhc.common.core.domain.AjaxResult;
import com.cxhc.common.enums.BusinessType;
import com.cxhc.common.core.page.TableDataInfo;

/**
 * 治安检查Controller
 * 
 * @author Dhq
 * @date 2024-08-15
 */
@RestController
@RequestMapping("/api/SecInvestigation")
public class ApiRpSecInvestigation extends BaseController
{
    @Autowired
    private IRpSecInvestigationService rpSecInvestigationService;

    /**
     * 查询治安检查列表
     */
    @PostMapping("/list")
    public TableDataInfo list(@RequestBody RpSecInvestigationVo rpSecInvestigationVo)
    {
        PageHelper.startPage(rpSecInvestigationVo.getPageNum(),rpSecInvestigationVo.getPageSize(),"AddTime desc");
        RpSecInvestigation rpConAdjust = RpSecInvestigationMapStructMapper.
                INSTANCE.RpSecInvestigationVoToRpSecInvestigation(rpSecInvestigationVo);
        List<RpSecInvestigation> list = rpSecInvestigationService.selectRpSecInvestigationList(rpConAdjust);
        return getDataTable(list);
    }


    /**
     * 获取治安检查详细信息
     */
    @GetMapping(value = "/details/{ID}")
    public AjaxResult getInfo(@PathVariable("ID") Long ID)
    {
        return success(rpSecInvestigationService.selectRpSecInvestigationByID(ID));
    }

    /**
     * 新增治安检查
     */
    @PostMapping("/insert")
    public AjaxResult add(@RequestBody RpSecInvestigationVo rpSecInvestigationVo)
    {
        RpSecInvestigation rpConAdjust = RpSecInvestigationMapStructMapper.
                INSTANCE.RpSecInvestigationVoToRpSecInvestigation(rpSecInvestigationVo);
        return toAjax(rpSecInvestigationService.insertRpSecInvestigation(rpConAdjust));
    }

    /**
     * 修改治安检查
     */
    @PostMapping("/update")
    public AjaxResult edit(@RequestBody RpSecInvestigation rpSecInvestigation)
    {
        return toAjax(rpSecInvestigationService.updateRpSecInvestigation(rpSecInvestigation));
    }

    /**
     * 删除治安检查
     */

    @GetMapping(value = "/delete/{ID}")
    public AjaxResult remove(@PathVariable Long ID)
    {
        return toAjax(rpSecInvestigationService.deleteRpSecInvestigationByID(ID));
    }
}
